<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        /*--------------------- 测试js中的数据类型 ------------------------*/
        var types = function() {
            var a = 1;
            var b = '2';
            var c = true;
            var d;
            var e = null;

            var person = {"name": "zhangsan", "age": 1};
            var arr = [1,2,"3"];
            var fun = types2;
            var date = new Date();
            var regExp = new RegExp();
            var error = new Error();

            let sym = Symbol('description');

            console.log("数字, a = " + typeof a);
            console.log("字符串, b = " + typeof b);
            console.log("布尔, c = " + typeof c);
            console.log("未定义, d = " + typeof d);
            console.log("null, e = " + typeof e);

            console.log("对象, person = " + typeof person);
            console.log("数组, arr = " + typeof arr); 
            console.log("函数, fun = " + typeof fun);
            console.log("日期, date = " + typeof date);
            console.log("正则, regExp = " + typeof regExp);
            console.log("异常, error = " + typeof error);

            console.log("大数, bigInt = " + typeof BigInt);
            console.log("Symbol = " + typeof sym);


            var regExp = /^abc.*$/
            console.log("-----" + regExp.test('abcsss'))
        }

        function types2() {}

        /*--------------------- 测试模板字符串 ------------------------*/
        function templateStr(){
            let name = "小明"
            console.log(`你好${name}`)
        }

        /*--------------------- 测试结构表达式 ------------------------*/
        let analyticalExpression = function() {
            let arr1 = [1,2,3]
            let [a,b,c,d=20] = arr1
            console.log(`a = ${a}, b = ${b}, c = ${c}, d = ${d}`)

            let person = {name:"小明", age:24, score:89}
            let {name, age, score, xx = 'jjjj'} = person
            console.log(`name = ${name}, age = ${age}, score = ${score}, xx = ${xx}`)

            let result = fun1([1, 2])
            console.log(`result = ${res}`)
        }

        let fun1 = function([a,b]) {
            return a + b
        }

        /*--------------------- 测试rest和spread参数 ------------------------*/
        

        /*--------------------- 测试箭头函数 ------------------------*/

    </script>
</head>
<body>
    <h1>hello vocode</h1>
    <button onclick="types()">查看js中个数据的类型</button>
    <button onclick="templateStr()">测试模板字符串</button>
    <button onclick="analyticalExpression()">测试结构表达式</button>
    
</body>
</html>